package com.yao2san.simdif.controller;

import com.yao2san.common.response.ResponseData;
import com.yao2san.simdif.bean.request.DatasourceSyncReq;
import com.yao2san.simdif.bean.request.DbDiffReq;
import com.yao2san.simdif.bean.request.DiffReportDownloadReq;
import com.yao2san.simdif.service.DbDifService;
import com.yao2san.simdif.service.DiffReportService;
import com.yao2san.simdif.service.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("diff")
public class DiffController {
    @Autowired
    private DbDifService dbDifService;

    @Autowired
    private DiffReportService diffReportService;
    @PostMapping("analysis")
    public ResponseData<Result> add(@RequestBody DbDiffReq req) {
        return ResponseData.success(dbDifService.dif(req));
    }

    @PostMapping("report")
    public void downloadReport(HttpServletResponse response, @RequestBody DiffReportDownloadReq req) {
        diffReportService.download(response,req);
    }
}
